package edu.nanyang.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import edu.nanyang.dao.MajorInfoDao;
import edu.nanyang.domain.MajorInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class MajorInfoService {
    @Resource
    private MajorInfoDao majorInfoDao;

    /**
     * 分页查询
     *
     * @param page     当前页数
     * @param pageSize 每页个数
     * @return
     */
    public PageInfo<MajorInfo> search(int page, int pageSize) {
        PageHelper.startPage(page, pageSize);//改写语句实现分页查询
        List<MajorInfo> all = majorInfoDao.findAll();
        PageInfo<MajorInfo> info = new PageInfo<>(all);
        return info;
    }

    public List<MajorInfo> findAll() {
        return majorInfoDao.findAll();
    }

    public  int delete(int id){
        return majorInfoDao.delete(id);
    }

    public int add(MajorInfo majorInfo){
        return majorInfoDao.add(majorInfo);
    }

    public MajorInfo getById(int id){
        return majorInfoDao.getById(id);
    }

    public int update(MajorInfo majorInfo){
        return majorInfoDao.update(majorInfo);
    }

}
